# forms.py
from wtforms import Form, SelectField, StringField
from wtforms.validators import Length
from flask import current_app  # 导入 Flask 应用的实例


class RegisterForm(Form):
    engine = SelectField('Engine', coerce=int)
    wd = StringField('Search Content', validators=[Length(min=0, message='内容格式错误')])

    def __init__(self, *args, **kwargs):
        super(RegisterForm, self).__init__(*args, **kwargs)
        self.engine.choices = current_app.config['ENGINES']